<div class="page-title">

    <div class="title-env">
        <h1 class="title">代理申请详情</h1>
    </div>

    <div class="breadcrumb-env">

        <ol class="breadcrumb bc-1">
            <li>
                <a href="{:url('/')}"><i class="fa-home"></i>Home</a>
            </li>
            <li>

                <a href="{:url('district/index')}">District</a>
            </li>
            <li class="active">

                <strong>EditApp</strong>
            </li>
        </ol>

    </div>

</div>
<div class="panel panel-default">


    <div class="panel-body">

        <form role="form" id="form1" method="post" action="{:url('district/editApp')}" class="validate">
            <input type="hidden" name="id" id="id" value="{$data['id']}">
            <div class="form-group">
                <label class="control-label">分区名称</label>

                <input type="text" class="form-control" value="{$district['name']}" readonly />
            </div>
            <div class="form-group">
                <label class="control-label">用户名</label>

                <input type="text" class="form-control" readonly value="{$data['username']}" />
            </div>
            <div class="form-group">
                <label class="control-label">手机号</label>

                <input type="text" class="form-control" readonly value="{$data['mobile']}" />
            </div>
            <div class="form-group">
                <label class="control-label">归属地</label>

                <input type="text" class="form-control" readonly value="{$data['province']} {$data['city']} {$data['district']}" />
            </div>
            <div class="form-group">
                <label class="control-label">当前状态</label>

                <input type="text" class="form-control" readonly value="{switch name='$data.status'}{case value='1'}等待审核{/case}{case value='2'}已通过{/case}{case value='3'}已拒绝{/case}{case value='4'}已支付{/case}{/switch}" />
            </div>
            <div class="form-group">
                <label class="control-label">申请时间</label>

                <input type="text" class="form-control" readonly value="{:date('Y-m-d H:i:s', $data['create_time'])}" />
            </div>
            <div class="form-group">
                <label class="control-label">支付状态</label>

                <input type="text" class="form-control" readonly value="{$data['pay_status']==1?'等待付款':'已付款'}" />
            </div>
            <div class="form-group">
                <label class="control-label">代理账号</label>

                <input type="text" class="form-control" id="loginname" name="loginname" data-validate="required" placeholder="账号" value="{$data['loginname']}" />
            </div>
            <div class="form-group">
                <label class="control-label">代理密码</label>

                <input type="text" class="form-control" id="password" name="password" data-validate="required" placeholder="密码" value="{$data['password']}" />
            </div>
            <div class="form-group">
                <label class="control-label">拒绝原因</label>
                <textarea id="reason" name="reason" class="form-control"></textarea>
            </div>
            <input type="hidden" name="status" id="status" value="{$data['status']}">
            <input type="hidden" name="district_id" value="{$data['district_id']}">
            <div class="form-group">
                {eq name="$data['status']" value="1"}
                <button type="button" onclick="formsubmit(2)" class="btn btn-success">通过</button>
                <button type="button" onclick="formsubmit(3)" class="btn btn-danger">拒绝</button>
                {else/}
                <button type="button" onclick="resetPassword()" class="btn btn-success">重置密码</button>
                <button type="button" onclick="history.back(-1)" class="btn btn-primary">返回</button>
                {/eq}
            </div>

        </form>

    </div>

</div>

{$code=='err4'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 登录账号重复了
    </div>
</div>

':''}
{$code=='err4'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 该用户已是其他区的代理
    </div>
</div>

':''}
{$code=='err3'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 用户不存在
    </div>
</div>

':''}
{$code=='err1'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 修改失败
        .请重新添加
    </div>
</div>

':''}

{$code=='err2'?'
<div class="col-md-6">
    <div class="alert alert-danger" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 糟糕 !</strong> 缺少字段
    </div>
</div>

':''}
{$code==0?'
<div class="col-md-6">
    <div class="alert alert-success" id="alert" style="position:fixed;right:0px;bottom:0px;  width: 350px">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true">×</span>
            <span class="sr-only">Close</span>
        </button>
        <strong> 成功</strong>
    </div>
</div>

':''}
<script>
    setTimeout("$('#alert').fadeOut(1000)",2000)
</script>
<script type="text/javascript">
    function formsubmit(status) {
        if(status == 2) {
            var loginname = $('#loginname').val();
            var password = $('#password').val();
            if(loginname == '' || password == '') {
                layer.msg('用户名和密码不能为空');
                return false;
            }
            if(!confirm('确定要通过吗？')) {
                return false;
            }
        } else if(status == 3) {
            var reason = $('#reason').val();
            if(reason == '') {
                layer.msg('拒绝原因不能为空');
                return false;
            }
            if(!confirm('确定要拒绝吗？')) {
                return false;
            }
        } else {
            return false;
        }
        $('#status').val(status);
        $('#form1').submit();
    }
    function resetPassword()
    {
        var password = $('#password').val();
        var id = $('#id').val();

        if(password == '') {
            alert('密码不能为空');
        }

        if(!confirm('确定要重置密码吗？')) {
            return false;
        }

        $.post('{:url("/index/district/resetPassword")}',{'password':password,'id':id}, function(res){
            alert(res.msg);
        },'json')
    }
</script>